/**
 * Created by Administrator on 2017/11/13 0013.
 */
var path = "http://192.168.1.24:8088/smart-campus/";

//ͼƬ��ַ
var photoPath ="http://192.168.1.24:8080/";
//  www.topzr.com:8080
//��ȡ��ַ����
function getParam(param){
    var url=location.search;
    var ename;
    var Request = new Object();
    if(url.indexOf("?")!=-1) {
        var str = url.substr(1);
        strs= str.split("&");
        for(var i=0;i<strs.length;i++ ){
            Request[strs[i].split("=")[0]]=(strs[i].split("=")[1]);
        }
    }
    return Request[param];
}


//���ڱ任�ķ���
function transferDate(date) {

    // ��
    var year = date.getFullYear();
    // ��
    var month = date.getMonth() + 1;
    // ��
    var day = date.getDate();

    if (month >= 1 && month <= 9) {

        month = "0" + month;
    }
    if (day >= 0 && day <= 9) {

        day = "0" + day;
    }

    var dateString = year + '/' + month + '/' + day;

    return dateString;
}

//��ȡ����ʱ��
function getWeek(Fn) {

    //������Ϊһ�ܵ����һ�����
    var date = new Date();

    //���������ܵĵڼ���
    var today = date.getDay();

    //�����վ�������������������ʾ��
    var stepSunDay = -today + 1;

    // �������������
    if (today == 0) {

        stepSunDay = -7;
    }

    // ��һ��������������������ʾ��
    var stepMonday = 7 - today;

    var time = date.getTime();

    var monday = new Date(time + stepSunDay * 24 * 3600 * 1000);
    var sunday = new Date(time + stepMonday * 24 * 3600 * 1000);

    //����һ������ ����ʼ���ڣ�
    var startDate = transferDate(monday); // ���ڱ任
    //�����յ����� ���������ڣ�
    var endDate = transferDate(sunday); // ���ڱ任


    return startDate + ' - ' + endDate;
}


//��ȡ��ǰ�ܵ�һ��
function getWeekStartDate(i){
    return formatDate(new Date(now.getFullYear(), nowMonth, nowDay - nowDayOfWeek-i+1));
}

//��ȡ��ǰ�����һ��
function getWeekEndDate(i){
    return formatDate(new Date(now.getFullYear(), nowMonth, nowDay + (6 - nowDayOfWeek-i)+1));
}

//ת����  ��-��-�� ��ʽ
function formatDate(date) {
    var myyear = date.getFullYear();
    var mymonth = date.getMonth()+1;
    var myweekday = date.getDate();

    if(mymonth < 10){
        mymonth = "0" + mymonth;
    }
    if(myweekday < 10){
        myweekday = "0" + myweekday;
    }
    return (myyear+"-"+mymonth + "-" + myweekday);
}

//��ȡ����
function upWeek(){
    changeWeek(7*count);
    changeMonth(7*count);
    if(count==0){
        ajaxGetRoom(getWeekStartDate(0),getWeekEndDate(0));
    }else if(count<0){
        ajaxGetRoomDown(getWeekStartDate(7*count),getWeekEndDate(7*count));
    }else{

        ajaxGetRoomUp(getWeekStartDate(7*count),getWeekEndDate(7*count));
        //ajaxGetRoomUp();
    }

    count++;
}

//��ȡ����
function downWeek(){
    changeWeek((7*(count-1))-7);
    changeMonth((7*(count-1))-7);
    if(count==2){
        ajaxGetRoom(getWeekStartDate(0),getWeekEndDate(0));
    }else if(count>2){
        ajaxGetRoomUp(getWeekStartDate((7*(count-1))-7),getWeekEndDate((7*(count-1))-7));
        //ajaxGetRoomUp();
    }else{
        ajaxGetRoomDown(getWeekStartDate((7*(count-1))-7),getWeekEndDate((7*(count-1))-7));
    }

    count--;
}

